﻿using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using MilkTeaMachine.OfflineClient.Models;

namespace MilkTeaMachine.OfflineClient.EntityFrameworkCore.Models;

[Table("tb_formula")]
public class Formula
{
    [Key] public int Id { get; set; }
    [MaxLength(256)] public required string Name { get; set; }
    [MaxLength(8), MinLength(8)] public required string Code { get; set; }
    public int TotalWeight { get; set; }
    public int ColdWaterWeight { get; set; }
    public int HotWaterWeight { get; set; }
    public int IceWeight { get; set; }
    public required WaterTypeEnum AddWaterType { get; set; }
    public required CupTypeEnum CupType { get; set; }
    public required SugarTypeEnum SugarType { get; set; }
    public required IceTypeEnum IceType { get; set; }

    public static char GetCupTypeCode(CupTypeEnum cupTypeEnum) => ((int)cupTypeEnum).ToString()[0];
    public static char GetSugarTypeCode(SugarTypeEnum sugarTypeEnum) => ((int)sugarTypeEnum).ToString()[0];
    public static char GetIceTypeCode(IceTypeEnum iceTypeEnum) => ((int)iceTypeEnum).ToString()[0];
}

public enum WaterTypeEnum
{
    无 = 0,
    热水 = 1,
    冰水 = 2
}